﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Utils;

namespace COFE.Core.Filter
{
    public interface IFilter
    {
        string Type { get; }
        string Value { get; }        
    }

    public static class IFilterExtension
    {

        public static int GetPriority(this IFilter filter)
        {
            if (filter is PropertyEntryFilter)
                return 0;
            return FilterAttribute.GetFilterAttribute(filter).Priority;
        }

        public static string GetSearchString(this IFilter filter)
        {
            return COFEShared.FilterParser.FilterToFilterString(filter);
        }

        public static Guid GetId(this IFilter filter)
        {            
           return StringUtils<IFilter>.
                GetDeterministicGuid(filter.GetSearchString().ToLower());
        }

    }
}
